package com.szqhyxj.youxiangju.biz.partnerHome.shop.order;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.szqhyxj.youxiangju.BaseActivity;
import com.szqhyxj.youxiangju.R;
import com.szqhyxj.youxiangju.biz.merchantHome.CustomViewPager;
import com.szqhyxj.youxiangju.biz.partnerHome.shop.OrderFragmentAdapter;
import com.szqhyxj.youxiangju.sys.components.NavigationBar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PartnerOrderListActivity extends BaseActivity implements NavigationBar.NavigationBarListener{

    @BindView(R.id.navigationBar)
    NavigationBar navigationBar;
    @BindView(R.id.my_order)
    RadioButton myOrder;
    @BindView(R.id.upgrade_order)
    RadioButton upgradeOrder;
    @BindView(R.id.card_chooser)
    RadioGroup cardChooser;
    @BindView(R.id.my_order_line)
    RadioButton myOrderLine;
    @BindView(R.id.upgrade_order_line)
    RadioButton upgradeOrderLine;
    @BindView(R.id.card_line)
    RadioGroup cardLine;
    @BindView(R.id.custom)
    CustomViewPager custom;

    private List<Fragment> fragments;

    public static void start(Activity activity){
        Intent intent = new Intent();
        intent.setClass(activity,PartnerOrderListActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_partner_order_list);
        ButterKnife.bind(this);
        navigationBar.setNavigationBarListener(this);

        fragments = new ArrayList<>();
        fragments.add(new MyOrderListFragment());
        fragments.add(new SubordinateOrderListFragment());

        OrderFragmentAdapter adapter = new OrderFragmentAdapter(getSupportFragmentManager(),fragments);
        custom.setAdapter(adapter);
        custom.setOffscreenPageLimit(0);
    }

    @OnClick({R.id.my_order, R.id.upgrade_order})
    public void onViewClicked(View view){
        switch(view.getId()){
            case R.id.my_order:
                custom.setCurrentItem(0);
                cardLine.check(R.id.my_order_line);
                break;
            case R.id.upgrade_order:
                custom.setCurrentItem(1);
                cardLine.check(R.id.upgrade_order_line);
                break;
        }
    }

    @Override
    public void navigationLeft(){
        finish();
    }

    @Override
    public void navigationRight(){ }
}
